import {Events, showNotifyEventType, webExtDomId} from "../../WebExtension/src/common/Utils.ts";

function getDom() {
  const installNode = document.getElementById(webExtDomId) as HTMLDivElement;
  if (installNode) {
    return installNode
  }
}

export function sendNoticeMessage(ev: showNotifyEventType) {
  const dom = getDom()
  if (dom) {
    const event = new CustomEvent<showNotifyEventType>(Events.showNotify, {
      detail: ev
    })
    dom.dispatchEvent(event)
  }
}
